/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rafkind.resrev.web.page.component;

import com.rafkind.resrev.data.User;
import com.rafkind.resrev.web.page.EditUser;
import org.apache.wicket.Page;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

/**
 *
 * @author Fictional Hero
 */
public class AddUserButton extends Panel {

  public AddUserButton(String id, IModel<Page> model) {
    super(id, model);
    Form addUserForm = new Form("addUserForm");
    
    
    addUserForm.add(new Button("addUserButton", new Model("Add New User")){
          @Override
          public void onSubmit() {
            Page page = (Page) AddUserButton.this.getDefaultModelObject();
            setResponsePage(
              new EditUser(
                new Model(
                  new User()), page));
          }          
        });
        
    add(addUserForm);
  }
}
